package com.android.server.mock;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Process;

import java.util.ArrayList;
import java.util.List;

public class PmUtil {
    public static final String TAG = "PmUtil";

    // 获取三方应用的应用列表
    public static List<ApplicationInfo> getInstalledApplications(
            PackageManager packageManager, int flags, int userId) {
        List<ApplicationInfo> apps = packageManager.getInstalledApplicationsAsUser(flags, userId);
        List<ApplicationInfo> installedApplication = new ArrayList<>();
        for (ApplicationInfo applicationInfo : apps) {
            if (!(applicationInfo.isSystemApp() || applicationInfo.isUpdatedSystemApp())
                    && applicationInfo.uid > Process.FIRST_APPLICATION_UID) {
                installedApplication.add(applicationInfo);
            }
        }
        return installedApplication;
    }
}
